# @configure_input@

### Path settings
srcdir		= @srcdir@
top_srcdir	= @top_srcdir@
top_builddir    = @top_builddir@
prefix		= @prefix@
exec_prefix	= @exec_prefix@
bindir		= @bindir@
libdir		= @libdir@
includedir	= @includedir@

PACKAGE_NAME	= @PACKAGE_NAME@
PACKAGE_VERSION	= @PACKAGE_VERSION@

@ENCAP_DEFS@

### Installation programs and flags
INSTALL		= @INSTALL@
INSTALL_PROGRAM	= @INSTALL_PROGRAM@ -s
INSTALL_DATA	= @INSTALL_DATA@
LN_S		= @LN_S@
MKDIR		= @MKDIR@

### Compiler and link options
CC		= @CC@
LIBTOOL         = @LIBTOOL@
CPPFLAGS	= -I. \
		  -I.. \
		  -I${srcdir} \
		  -I${top_srcdir}/compat \
		  -I../listhash \
		  @CPPFLAGS@
CFLAGS		= @CFLAGS@
LDFLAGS		= @LDFLAGS@
LIBS		= @LIBS@
LTLIBOBJS	= @LTLIBOBJS@
RANLIB		= @RANLIB@
@SET_MAKE@
VPATH		= @srcdir@:@top_srcdir@/compat:../listhash


### Makefile rules - no user-servicable parts below

LIBTAR_OBJS	= append.lo \
		  block.lo \
		  decode.lo \
		  encode.lo \
		  extract.lo \
		  handle.lo \
		  libtar_hash.lo \
		  libtar_list.lo \
		  output.lo \
		  util.lo \
		  wrapper.lo
LIBTAR_HDRS	= ../config.h \
		  ${top_srcdir}/compat/compat.h \
		  ${srcdir}/libtar.h \
		  ${srcdir}/internal.h \
		  ../listhash/libtar_listhash.h
LIBTAR_LIBS	= ./libtar.la
ALL		= libtar.la
LDFLAGS		= @LDFLAGS@
CFLAGS		= @CFLAGS@

DISTCLEANFILES	= ../listhash/libtar_listhash.h \
		  ../listhash/libtar_list.c \
		  ../listhash/libtar_hash.c


all: ${ALL}

.PHONY: clean distclean install

libtar.la: ${LIBTAR_OBJS} ${LTLIBOBJS}
	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o libtar.la $(LIBTAR_OBJS) $(LTLIBOBJS) -rpath $(libdir)
#	${AR} rc libtar.a ${LIBTAR_OBJS} ${LIBOBJS}
#	${RANLIB} libtar.a

${LIBTAR_OBJS}: ${LIBTAR_HDRS}

%.lo: $(srcdir)/%.c
	$(LIBTOOL) --mode=compile ${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $<

%.lo: listhash/%.c
	$(LIBTOOL) --mode=compile ${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $<

%.lo: compat/%.c
	$(LIBTOOL) --mode=compile ${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $<

clean:
	rm -rf *~ *.o $(LIBTAR_OBJS) ${ALL} core .libs $(LTLIBOBJS)

distclean: clean
	rm -f Makefile ${DISTCLEANFILES}

install: ${ALL}
	${MKDIR} ${DESTDIR}${libdir}
	$(LIBTOOL) --mode=install ${INSTALL_DATA} libtar.la ${DESTDIR}${libdir}
	${MKDIR} ${DESTDIR}${includedir}
	${INSTALL_DATA} ${srcdir}/libtar.h ${DESTDIR}${includedir}
	${INSTALL_DATA} ../listhash/libtar_listhash.h ${DESTDIR}${includedir}

